package lesson14;

public class Car {
	String model;
	int maxSpeed;
	int currentSpeed;
	String color;
	byte currentGear;
	Person owner;
	
	void accelerate(int speed){
		if(currentSpeed + speed > maxSpeed){
			currentSpeed = maxSpeed;
		}else currentSpeed += speed;
		if(speed > 30){
			changeGearUp(1);
		}
		
	}
	
	void changeGearDown(int gear){
		if(currentGear - gear < 1){
			currentGear = 1;
		}else currentGear--;
	}
	void changeGearUp(int gear){
		if(currentGear + gear > 6){
			currentGear = 6;
		}else currentGear++;
	}
	void changeColor(String newColor) {color = newColor;}
	void changeGear(byte newGear){
		if(newGear<1){
			currentGear=1;
		}else if(newGear>6){
			currentGear = 6;
		}else 
			currentGear=newGear;
	}
}
